function posterior = updatePosteriorKmeans(mix, data, vars)


% update each component
for k = 1:mix.ncentres
    w = vars.Z(:, k);

    varposterior = computeBayesKmean(mix.varprior, data, w);
  
    if isfield(mix.varprior, 'a0')
        posterior.a(k) = mix.varprior.a0 + sum(w);
    end
    posterior.m(k, :) = varposterior.m;
    posterior.T(:, :, k) = varposterior.T;
end
